package backend.model.admin;

import backend.model.base.DBModel;

import javax.persistence.*;

@NamedQueries({@NamedQuery(name = "findAllForeignManagers", query = "from ForeignManager"),
        @NamedQuery(name = "findAllActiveForeignManagers", query = "from ForeignManager where isActive = true"),
        @NamedQuery(name = "findForeignManagerByFirstAndLastName", query = "from ForeignManager where firstName = :firstName and lastName = :lastName")})

@Entity
@Table(name = "foreign_manager")
public class ForeignManager extends DBModel {

    @Id
    @GeneratedValue
    @Column(name = "id")
    private int id;

    @Column(name = "first_name")
    private String firstName;

    @Column(name = "last_name")
    private String lastName;

    @Column(name = "is_active")
    private boolean isActive;

    @Override
    public int getId() {
        return id;
    }

    public void setActive(boolean active) {
        this.isActive = active;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public String getLastName() {
        return lastName;
    }

    @Override
    public boolean getIsActive() {
        return isActive;
    }

    @Override
    public int compareTo(Object o) {
        if (!(o instanceof ForeignManager)) {
            return -1;
        } else {
            ForeignManager otherManager = (ForeignManager) o;
            return getDisplayLabel().compareTo(otherManager.getDisplayLabel());
        }
    }

    @Override
    public String getDisplayLabel() {
        return firstName + " " + lastName;
    }
}
